package com.xuecheng.content.api;

import com.xuecheng.base.exception.ValidationGroups;
import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 顾梦
 * @description 教师信息接口
 * @since 2023/7/13
 */
@Api(value = "教师信息接口", tags = "教师信息接口")
@RestController
@Slf4j
public class CourseTeacherController {

    @Resource
    private CourseTeacherService courseTeacherService;

    @GetMapping("/courseTeacher/list/{courseId}")
    @ApiOperation("查询教师信息")
    public List<CourseTeacher> list(@PathVariable Long courseId) {
        return courseTeacherService.queryCourseTeacher(courseId);
    }

    @PostMapping("/courseTeacher")
    @ApiOperation("添加或修改教师")
    public CourseTeacher addOrModifyCourseTeacher(@RequestBody CourseTeacherDto courseTeacherDto) {
        Long companyId = 1232141425L;
        if (courseTeacherDto.getId() == null){
            return courseTeacherService.addCourseTeacher(companyId,courseTeacherDto);
        }else {
            return courseTeacherService.modifyCourseTeacher(companyId,courseTeacherDto);
        }

    }

    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    @ApiOperation("删除教师")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable Long id){
        Long companyId = 1232141425L;
        courseTeacherService.deleteCourseTeacher(companyId,courseId,id);
    }

}
